package ink.lovejinhu.leetcode;

import ink.lovejinhu.common.TreeNode;

/**
 * @author jinhu
 * created 2021-07-14 15:18
 */
public class Solution_0404 {
    /**
     * 左叶子之和
     *
     * @param root
     * @return
     */
    public int sumOfLeftLeaves(TreeNode root) {
        this.print(root);
        return res;
    }

    public int res = 0;

    public void print(TreeNode root) {
        if (root == null) return;
        if (root.left != null && root.left.left == null && root.left.right == null) {
            res += root.left.val;
        }
        print(root.left);
        print(root.right);
    }

}
